package com.luoy;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;

/**
 * @description：
 * @author： LUOYUAN
 * @date： 2019-09-20-15:24
 * @function：
 */

public class RestTemplate {

    //       @Value("${restTemplate.connectionRequestTimeout}")
//        private int connectionRequestTimeout; //连接请求超时时间
//
//        @Value("${restTemplate.connectionTimeout}")
//        private int connectionTimeout;        //连接超时时间
//
//        @Value("${restTemplate.readTimeout}")
//        private int readTimeout;              //读取超时时间

    @Bean
    @Primary
    public org.springframework.web.client.RestTemplate customRestTemplate(){
        HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
        httpRequestFactory.setConnectionRequestTimeout(100000);
        httpRequestFactory.setConnectTimeout(100000);
        httpRequestFactory.setReadTimeout(100000);
        return new org.springframework.web.client.RestTemplate(httpRequestFactory);
    }
}
